package nowcoder.hw.hj17;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static Pattern pattern = Pattern.compile("(^|;)([WASD])(\\d+)(?=;)");

    public static void main(String[] args) throws IOException {

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String cmd = bufferedReader.readLine();
//            Pattern pattern = Pattern.compile("(^|;)([WASD])(\\d+)(?![WASD0-9])");
        Matcher matcher = pattern.matcher(cmd);
        int x = 0, y = 0;
        while (matcher.find()) {
            System.out.println(matcher.group());
            if (matcher.group() == null || matcher.group().trim().equals("")) continue;
            Integer step = Integer.valueOf(matcher.group(3));
            switch (matcher.group(2)) {
                case "W": {
                    y += step;
                    break;
                }
                case "A": {
                    x -= step;
                    break;
                }

                case "S": {
                    y -= step;
                    break;
                }
                case "D": {
                    x += step;
                    break;
                }
            }
        }

        System.out.println(x + "," + y);

    }
}